import React, {Fragment, PureComponent} from 'react';
import {connect} from 'dva';
import moment from 'moment';
import router from 'umi/router';
import {Badge, Button, Card, Col, Divider, Dropdown, Form, Icon, Input, Menu, Modal, Row, Select, Steps,} from 'antd';
import TableList from '@/components/TableList';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import SimpleDownloadApplyCreateForm from "./sub/SimpleDownloadApplyCreateForm";
import TreasurySynergy from "./sub/TreasurySynergy";
import EditApplyCreateForm from "./sub/EditApplyCreateForm";
import styles from './PrivateFile.less';
import DescriptionList from '@/components/DescriptionList';
import CreateOrUpdateDirForm from './sub/CreateOrUpdateDirForm';
import UploadFileForm from './sub/UploadFileForm';
import FlowCreateForm from './sub/FlowCreateForm';
import OutCreateForm from './sub/OutCreateForm';
import MoveFileForm from './sub/MoveFileForm';
import CopyFileForm from './sub/CopyFileForm';
import ShareToForm from './sub/ShareToForm';
import DirLine from "./sub/DirLine";
import {getReadableSize, hasInstalledEditApp,} from '@/utils/dsrsUtil';
import {decode, encode,} from '@/utils/AesUtil';
import ScanResultFormNew from "./sub/ScanResultFormNew";
import {getConfigs, getFileCodeToname} from '@/utils/bwdautil';
import wordIcon from '@/iconImg/word.png';
import excelIcon from '@/iconImg/excel.png';
import pptIcon from '@/iconImg/ppt.png';
import pdfIcon from '@/iconImg/pdf.png';
import zipIcon from '@/iconImg/zip.png';
import txtIcon from '@/iconImg/txt.png';
import picIcon from '@/iconImg/pic.png';
import csvIcon from '@/iconImg/csv.png';
import otherIcon from '@/iconImg/other.png';
import batIcon from '@/iconImg/bat.png';
import sqlIcon from '@/iconImg/sql.png';
import shIcon from '@/iconImg/sh.png';

const {Description} = DescriptionList;
const FormItem = Form.Item;
const {Step} = Steps;
const {TextArea} = Input;
const {Option} = Select;
const getValue = obj =>
  Object.keys(obj)
    .map(key => obj[key])
    .join(',');

const formLayout = {
  labelCol: {span: 6},
  wrapperCol: {span: 18},
};

/* eslint react/no-multi-comp:0 */
@connect(({privateFileModel, loading}) => ({
  privateFileModel,
  loading: loading.models.privateFileModel,
}))
@Form.create()
class PrivateFile extends PureComponent {
  state = {
    flowModalVisible: false,//流转modal
    outModalVisible: false,//外发modal
    moveModalVisible: false,//移动文件
    downloadModalVisible: false,//移动文件
    shareModalVisible: false,
    treasuryVisible: false,
    orgTree: [],//the org tree
    flowFormValues: {},//流转表单数据
    outFormValues: {},//外发表单数据
    record: {},
    ids: '',
    currentDir: {id: 0},
    selectedRows: [],
    formValues: {},
    supportUploadFileTypes: "",//支持上传的文件类型  accept=".doc,.docx,"
    fileMaxUploadSize: "",//最大支持上传大小
    // currentDirs: [{id: 0, dirName: '根目录'}], //当前的目录，[{id:-1，dirName:'共享'},{id:-2，dirName:'常用'}]
    currentDirs: [{code: 'index', dirName: '我的文件库', id: ''}, {code: 'private_file', dirName: '个人文件', id: ''}],
    //共享详情
    shareViewVisible: false,
    scanResultViewVisible: false,
    shareViewData: [],
    authOptions: [],
    waterOptions: [],
    // 金库协
    jinkuPeople: [],
    jinkuUuid: "",
    records: [],
    scanRecord:{id:"",dirName :""}
  };

  columns = [
    {
      title: '文件名称',
      dataIndex: 'dirName',
      width: "30%",
      render: (text, row) => {
        if (row.dirType == 1) {
          return <Fragment>
            <Icon type="folder" theme="filled" style={{color: '#e87e04'}}/>&nbsp;
            <a onClick={() => this.openDir(row)}>{text}</a>&nbsp;
            {row.shareFlag == 1 ? <Icon type="share-alt" style={{color: '#40a9ff', cursor: 'pointer'}}
                                        onClick={() => this.shareViewHandelVisible(true, row)}
                                        title="共享详情"/> : null}&nbsp;
            {row.mostUseFlag == 1 ? <Icon type="star" style={{color: '#e87e04'}} title="收藏"/> : null}
          </Fragment>
        } else {
          let fielIcon = '';
          // let className = ' ';
          switch (row.fileSuffix) {
            case '.wps':
            case '.doc':
            case '.docx':
              fielIcon = wordIcon;             
              break;
            case '.txt':
              fielIcon = txtIcon;
              break;  
            case '.bat':             
              fielIcon = batIcon;
              break; 
            case '.sh':             
              fielIcon = shIcon;
              break;   
            case '.sql':             
              fielIcon = sqlIcon;
              break;   
            case '.ppt':
            case '.pptx':
              fielIcon = pptIcon;             
              break;          
            case '.xls':
            case '.xlsx':
              fielIcon = excelIcon; 
              break;   
            case '.pdf':
              fielIcon = pdfIcon; 
              break;
            case '.zip':
            case '.gz':
            case '.tar':
            case '.rar':
              fielIcon = zipIcon;              
              break;     
            case '.jpg':
            case '.png':
            case '.gif':
              fielIcon = picIcon;              
              break;  
            case '.csv':
              fielIcon = csvIcon;              
                break;              
            default:
              fielIcon = otherIcon;
          }
          return <Fragment>
            <img src={fielIcon} />&nbsp;
            <span title={text}>{text}</span>
            &nbsp;
            {row.shareFlag == 1 ? <Icon type="share-alt" style={{color: '#40a9ff', cursor: 'pointer'}}
                                        onClick={() => this.shareViewHandelVisible(true, row)}
                                        title="共享详情"/> : null}&nbsp;
            {row.mostUseFlag == 1 ? <Icon type="star" style={{color: '#e87e04'}} title="收藏"/> : null}
          </Fragment>
        }

      },
    },
    {
      title: '文件大小',
      dataIndex: 'fileSize',
      render: (text, record) => {
        if (text) {
          return getReadableSize(text * 1024);
        } else {
          return '--'
        }
      },
    },
    {
      title: '敏感等级',
      dataIndex: 'secretLevelName',
    },
    {
      title: '状态',
      dataIndex: 'scanState',
      render: (val, record) => {
        let text = "--";
        let status = "";
        if (val == 0) {
          status = "processing";
          text = "未处理";
        } else if (val == 1) {
          status = "processing";
          text = "处理中";
        } else if (val == 2) {
          status = "success";
          text = <a onClick={() => this.queryScanResult(record)}>已扫描</a>;
          // text = "已扫描";
        } else if (val == 3) {
          status = "error";
          text = "处理失败" + (record.remark ? ('(' + record.remark + ')') : '');
        } else if (val == 4) {
          text = "无需扫描";
          status = "success";
        }
        return <Badge status={status} text={text}/>;


      }

    },
    {
      title: '创建时间',
      dataIndex: 'createTime',
      render:
        val => <span>{moment(val).format('YYYY-MM-DD HH:mm:ss')}</span>,
    },
    {
      title: '操作',
      render:
        (text, record) => {
          /* const open = <a onClick={() => this.querySubDirOrFileList(record)}>打开</a>;*/
          /* const deleteRecord = <Popconfirm title="确定删除吗？" onConfirm={() => this.deleteItem(record.id)}>
             <a>删除</a></Popconfirm>;*/
          const configs = getConfigs() || {};
          const deleteRecord = <a onClick={() => this.deleteData(record.id)}>删除</a>;
          const preview = <a onClick={() => this.previewFile(record)}>预览</a>;
          const download = <a onClick={() => this.queryDownloadRight(record)}>下载</a>;
          const share = <a onClick={() => this.queryShareRight(record)}>共享</a>;
          const scanning = <a onClick={() => this.scan(record.id)}>扫描</a>;

          /*const notShare = <Popconfirm title='是否取消全部共享' onConfirm={() => this.removeShare(record)}>
            <a>取消共享</a>
          </Popconfirm>;*/
          const notShare = <a onClick={() => this.isShare(record)}>取消共享</a>;


          /*const mostUse = <Popconfirm title={record.mostUseFlag == 1 ? '是否取消设为常用' : '是否设为常用'}
                                      onConfirm={() => this.updateFileMostUse(record)}>
            <a>{record.mostUseFlag == 1 ? '取消常用' : '设为常用'}</a>
          </Popconfirm>;*/

          const mostUse = <a
            onClick={() => record.mostUseFlag == 1 ? this.CancelMostUse(record) : this.SetMostUse(record)}>{record.mostUseFlag == 1 ? '取消收藏' : '收藏'}</a>;

          // const flow = <a onClick={() => this.handleFlowModalVisible(true, record)}>流转</a>;
          const flow = <a onClick={() => this.queryFlowRight(record)}>流转</a>;
          const out = <a onClick={() => this.queryOutRight(record)}>外发</a>;
          const rename = <a onClick={() => this.handleDirModalVisible(true, record)}>重命名</a>;
          const edit = <a onClick={() => this.queryEditRight(record)}>编辑</a>
          const move = <a onClick={() => this.handleMoveModalVisible(true, record)}>移动</a>;
          const copy = <a onClick={() => this.handleCopyModalVisible(true, record)}>复制</a>;
          const Apply = props => (
            <Dropdown
              overlay={
                <Menu>
                  <Menu.Item>{flow}</Menu.Item>
                  <Menu.Item>{out}</Menu.Item>
                </Menu>
              }
            >
              <a>
                申请 <Icon type="down"/>
              </a>
            </Dropdown>
          );

          const MoreBtn = props => (
            <Dropdown
              overlay={
                //
                <Menu>
                  {configs.hideEdit ? null : <Menu.Item>{edit}</Menu.Item>}

                  <Menu.Item>{rename}</Menu.Item>
                  <Menu.Item>{move}</Menu.Item>
                  <Menu.Item>{copy}</Menu.Item>
                  <Menu.Item>{deleteRecord}</Menu.Item>
                  <Menu.Item>{mostUse}</Menu.Item>

                  {configs.hideShare ? null : <Menu.Item>{share}</Menu.Item>}
                  {configs.hideShare ? null : record.shareFlag == 1 ? <Menu.Item>{notShare}</Menu.Item> : null}
                </Menu>
              }
            >
              <a>
                更多 <Icon type="down"/>
              </a>
            </Dropdown>
          );
          if (record.dirType == 1) {
            //文件夹
            return <Fragment>
              {/*  {open}
              <Divider type="vertical"/>*/}
              {deleteRecord}
              <Divider type="vertical"/>
              {share}
              <Divider type="vertical"/>
              {rename}
              <Divider type="vertical"/>
              {record.shareFlag == 1 ? notShare : null}
            </Fragment>
          } else if (record.dirType == 0) {
            if (record.scanState == 2 || record.scanState == 0 || record.scanState == 4) {
              //文件
              return <Fragment>
                {scanning}

                {configs.hideDownload ? null : <Divider type="vertical"/>}
                {configs.hideDownload ? null : download}
                {configs.hidePreview ? null : <Divider type="vertical"/>}
                {configs.hidePreview ? null : preview}
                <Divider type="vertical"/>
                <Apply current={record}/>
                <Divider type="vertical"/>
                <MoreBtn current={record}/>
              </Fragment>
            } else {
              return <Fragment>
                {deleteRecord}
              </Fragment>
            }


          }

          return null;
        },
    }
    ,
  ]
  ;

  componentDidMount() {
    const {dispatch} = this.props;
    dispatch({
      type: 'privateFileModel/queryDirTreeList',
      payload: null,
    });
    this.querySubDirOrFileList({id: 0})
    this.queryUpload();
    this.queryOutRightControl();
    this.queryOutWaterControl();

    //组织管理员
    this.queryOrgAdmin();
    this.initFolderAddrName();
  }

  /**
   * 名称要是可配的，所以要可配
   */
  initFolderAddrName = () => {
    // getFileCodeToname
    // getFileCodeToname().forEach(item => {
    //   //把currentDirs 里的中文名称替换成配置那种
    //   }
    // );

  }
  queryDirTreeList = () => {
    const {dispatch} = this.props;
    dispatch({
      type: 'privateFileModel/queryDirTreeList',
      payload: null,
    });
  }

  /**
   * 编辑modal
   * @param item
   */
  showEditModal = item => {
    this.setState({
      visible: true,
      current: item,
    });
  };
  /**
   * 流转modal
   * @param item
   */
  showFlowModal = item => {
    this.setState({
      flowModalVisible: true,
      current: item,
    });
  };

  //查看共享详情
  shareViewHandelVisible = (flag, record) => {
    this.setState({
      shareViewVisible: !!flag,
      shareViewData: [],
    });
    if (flag && record) {
      this.queryShareDetail(record)
    }
  };

  // 获取金库协同人
  querySensitive = () => {
    const {dispatch} = this.props;
    dispatch({
      type: 'privateFileModel/sensitive',
      callback: (res) => {
        if (res.result == "ok" && res.data) {
          this.setState({
            jinkuPeople: res.data.helpPeoples,
            jinkuUuid: res.data.uuid,
          });
        }
      },
    });
  }


  // 金库协同--- 获取短信授权码
  querySms = (uuid, fields) => {
    const {dispatch} = this.props;

    let tempStr = fields.helppeople;
    let startIndex = tempStr.indexOf('[');
    let endIndex = tempStr.indexOf(']');
    let collaboration = tempStr.substring(startIndex + 1, endIndex);
    let params = {
      uuid: uuid,
      collaboration: collaboration,
    };

    dispatch({
      type: 'privateFileModel/sms',
      payload: params,
      callback: (res) => {
        if (res.result == "ok" && res.data) {
          // this.setState({});
        }
      },
    });
  }

  // 金库协同---验证
  checkSensitive =async (optType, records, uuid, fields) => {
    const {dispatch} = this.props;
    let moshi = fields.moshi;
    // gxdx[gxdx]
    let tempStr = fields.helppeople;
    let endIndex = tempStr.indexOf('[');
    let collaboration = tempStr.substring(0, endIndex);

    let params = {
      uuid: uuid,
      collaboration: collaboration,
      authzmode: moshi,
      authzState: 0,
    };

    // 1是短信   2是静态密码
    if (moshi == 1) {
      params.authzcode = fields.shouji;
    } else if (moshi == 2) {
      //如果是密码，要进行加密的
      params.authzcode =await encode(fields.mimaa);
    } else {
      Modal.error({title: '操作失败', content: "验证模式不对"});
      return;
    }


    dispatch({
      type: 'privateFileModel/checkSensi',
      payload: params,
      callback: (res) => {
        if (res.result == "ok" && res.data) {
          this.handleTreasuryVisible();
          // 进行原先的操作，
          this.noneAuditOpt(optType, records);

        } else {
          Modal.error({title: '操作失败', content: "验证失败"});
          return;
        }
      },
    });
  }

  /**
   * 查询共享详情
   * @param record
   */
  queryShareDetail = (record) => {
    const {dispatch} = this.props;
    let params = {id: record.id};
    dispatch({
      type: 'privateFileModel/queryShareDetail',
      payload: params,
      callback: (res) => {
        if (res.result == "ok" && res.data) {
          this.setState({
            shareViewData: res.data.dataList,
          });
        }
      },
    });
  }

  handleStandardTableChange = (pagination, filtersArg, sorter) => {
    const {dispatch} = this.props;
    const {formValues} = this.state;
    const {currentDir} = this.state;

    const filters = Object.keys(filtersArg).reduce((obj, key) => {
      const newObj = {...obj};
      newObj[key] = getValue(filtersArg[key]);
      return newObj;
    }, {});

    const params = {
      parentId: currentDir.id,
      pageNum: pagination.current - 1,
      pageSize: pagination.pageSize,
      ...formValues,
      ...filters,
    };
    if (sorter.field) {
      params.sorter = `${sorter.field}_${sorter.order}`;
    }

    dispatch({
      type: 'privateFileModel/queryMyFiles',
      payload: params,
    });
  };


  //展示常用文件
  showMostUse() {
    const {dispatch} = this.props;
    let queryForm = {mostUseFlag: 1};
    this.setState({
      currentDir: {id: 0},
    });
    dispatch({
      type: 'privateFileModel/queryMyFiles',
      payload: queryForm,
      callback: (res) => {
        if (res.result == "ok") {
          this.setDirLineToMostUse();
        } else {
          Modal.error({title: '操作失败', content: res.msg});
        }
      },
    });
  }

  // 展示我的共享
  showMyShare() {
    const {dispatch} = this.props;
    let queryForm = {shareFlag: 1};
    this.setState({
      currentDir: {id: 0},
    });
    dispatch({
      type: 'privateFileModel/queryMyFiles',
      payload: queryForm,
      callback: (res) => {
        if (res.result == "ok") {
          this.setDirLineToShare();
        } else {
          Modal.error({title: '操作失败', content: res.msg});
        }
      },
    });
  }

  // 扫描
  scan(id) {
    const {currentDir} = this.state
    const {dispatch} = this.props;
    dispatch({
      type: 'privateFileModel/queryScan',
      payload: {id},
      callback: (res) => {
        if (res.result == "ok") {
          this.querySubDirOrFileList(currentDir);
        } else {
          Modal.error({title: '操作失败', content: res.msg});
        }
      },
    });
  }


  setDirLineToShare = () => {
    //变成  首页》》个人文件》》我的共享,setState

    let currentDirs = [];
    currentDirs.push({code: 'index', dirName: '我的文件库', id: ''});
    currentDirs.push({code: 'private_file', dirName: '个人文件', id: ''});
    currentDirs.push({code: 'my_share', dirName: '我的共享', id: ''});
    this.setState({currentDirs: currentDirs});
  }
  setDirLineToMostUse = () => {
    // currentDirs.push({code: 'sub_file', dirName: params.dirName, id: params.id});
    // currentDirs.push({code: 'index', dirName: '首页', id: ''});
    // currentDirs.push({code: 'private_file', dirName: '个人文件', id: ''});
    // currentDirs.push({code: 'most_use', dirName: '收藏文件', id: ''});
    // currentDirs.push({code: 'my_share', dirName: '我的共享', id: ''});

    let currentDirs = [];
    currentDirs.push({code: 'index', dirName: '我的文件库', id: ''});
    currentDirs.push({code: 'private_file', dirName: '个人文件', id: ''});
    currentDirs.push({code: 'most_use', dirName: '收藏文件', id: ''});
    this.setState({currentDirs: currentDirs});
  }

  openDir = record => {
    let currentDirs = this.state.currentDirs;
    currentDirs.push({code: 'sub_file', dirName: record.dirName, id: record.id});
    this.setState({currentDirs: currentDirs});
    this.querySubDirOrFileList(record);
  }

  //显示文件夹下级内容
  querySubDirOrFileList = record => {

    const {dispatch} = this.props;


    let queryForm = {parentId: record.id || 0};
    this.setState({
      currentDir: record,
    });
    dispatch({
      type: 'privateFileModel/queryMyFiles',
      payload: queryForm,
      callback: (res) => {
        if (res.result == "ok") {
          this.setState({
            selectedRows: [],
          });
        } else {
          Modal.error({title: '操作失败', content: res.msg});
        }
      },
    });
  };


  /**
   * 查询组织树
   */
  queryOrgTree = () => {

    const {dispatch} = this.props;
    dispatch({
      type: 'privateFileModel/queryOrgTree',
      callback: (res) => {
        if (res.result == 'ok') {
          let data = res.data;
          this.setState({orgTree: data})
        }
      },
    });
  };


  previewItem = id => {
  };

  backToRoot() {
    this.onDirSelect({code: 'private_file'});
  }

  deleteData = (id) => {
    Modal.confirm({
      title: '删除',
      content: '您确定要删除以下数据吗？',
      okText: '确认',
      cancelText: '取消',
      onOk: () => this.deleteItem(id),
    });
  };

  batchDelete = (rows = []) => {
    const ids = rows.map((item) => {
      return item.id;
    }).join(",");
    this.deleteData(ids); //批量删除
  };

  deleteItem = id => {
    const {dispatch} = this.props;
    const {currentDir,} = this.state;
    dispatch({
      type: 'privateFileModel/deleteFileOrDir',
      payload: {
        ids: id,
      },
      callback: (res) => {
        if (res.result == "ok") {
          Modal.success({title: res.msg});
          this.querySubDirOrFileList(currentDir);
        } else {
          Modal.error({title: '操作失败', content: res.msg});
        }

      },
    });

  };


  // 下载
  handleDownload = (records, fields) => {
    const {dispatch} = this.props;

    const ids = records.map((item) => {
      return item.id;
    }).join(",");


    let params = {
      ids: ids,
      applyTitle: fields.applyTitle,
      applyReason: fields.applyReason,
      auditUserCode: fields.auditUserCode,
      type: 0,
    };
    dispatch({
      type: 'privateFileModel/privateFilesDownload',
      payload: params,
      callback: (res) => {
        if (res.result == "ok") {
          Modal.success({title: res.msg});
          this.handleDownloadModalVisible();
        } else {
          Modal.error({title: '操作失败', content: res.msg});
        }
      },
    });
  };

  // 编辑申请
  addEditApply = (record, fields) => {
    const {dispatch} = this.props;
    let params = {
      id: record.id,
      applyTitle: fields.applyTitle,
      applyReason: fields.applyReason,
      auditUserCode: fields.auditUserCode,
      type: 0,
    };
    dispatch({
      type: 'privateFileModel/editApply',
      payload: params,
      callback: (res) => {
        if (res.result == "ok") {
          Modal.success({title: res.msg});
          this.handleEditModalVisible();
        } else {
          Modal.error({title: '操作失败', content: res.msg});
        }
      },
    });


  };

  /**
   * 查询外发的权限
   */
  queryOutRightControl = () => {
    const {dispatch} = this.props;
    let params = {dataDictTypeCode: 'out_right_control', status: 0};
    dispatch({
      type: 'privateFileModel/queryOutRightControl',
      payload: params,
      callback: (res) => {
        if (res.result == "ok" && res.data) {
          let authOptions = [];
          res.data.dataList.forEach(item => {
            authOptions.push({label: item.dataDictName, value: item.dataDictValue});
          })

          this.setAuthOptions(authOptions);
        }
      },
    });
  };

  setAuthOptions = (options) => {
    this.setState({authOptions: options});
  }
  setWaterOptions = (options) => {
    this.setState({waterOptions: options});
  }


  queryOutWaterControl = () => {
    const {dispatch} = this.props;

    let params = {dataDictTypeCode: 'out_water_control', status: 0};
    dispatch({
      type: 'privateFileModel/queryOutWaterControl',
      payload: params,
      callback: (res) => {
        if (res.result == "ok" && res.data) {
          let waterOptions = [];
          res.data.dataList.forEach(item => {
            waterOptions.push({label: item.dataDictName, value: item.dataDictValue});
          })
          this.setWaterOptions(waterOptions);

        }
      },
    });
  };

  queryOrgAdmin = () => {
    const {dispatch} = this.props;
    dispatch({
      type: 'privateFileModel/queryOrgAdmin',
    });
  };


  /**
   * 查询支持上传的参数
   */
  queryUpload = () => {
    const {dispatch} = this.props;
    let params = {};
    dispatch({
      type: 'privateFileModel/queryUpload',
      payload: params,
      callback: (res) => {
        if (res.result == "ok" && res.data) {


          let originsupportUploadType = res.data.supportUploadType;
          let fileMaxUploadSize = res.data.fileMaxUploadSize;
          this.setState({supportUploadFileTypes: originsupportUploadType});
          this.setState({fileMaxUploadSize: fileMaxUploadSize});
        } else {

        }
      },
    });


  };


  /******************------------显示弹出框----------------start****************/
    // 下载
  handleDownloadModalVisible = (flag, records) => {
    if (!records) {
      records = [];
    }
    const ids = records.map((item) => {
      return item.id;
    }).join(",");

    this.setState({
      downloadModalVisible: !!flag,
      records: records,
      ids: ids,
    });
  };
  handleEditModalVisible = (flag, record) => {
    this.setState({
      editModalVisible: !!flag,
      record: record || {},
    });
  };
  /******************------------显示弹出框----------------end****************/

  /********************start*********无需审批，直接操作 0个人文件下载1公共文件2流转3外发4编辑*********************/

  confirmQuickDownload = (records) => {
    Modal.confirm({
      title: '下载',
      content: '您确定要下载吗？',
      okText: '确认',
      cancelText: '取消',
      onOk: () => this.quickDownload(records),
    });
  }

  quickDownload = (records) => {

    const ids = records.map((item) => {
      return item.id;
    }).join(",");
    const {dispatch} = this.props;
    dispatch({
      type: 'privateFileModel/quickDownload',
      payload: {
        ids,
      },
      callback: (res) => {
        if (res.result == "ok") {
          Modal.success({title: res.msg});
        } else {
          Modal.error({title: '操作失败', content: res.msg});
        }
      },
    });
  }

  /***编辑文件**/
  quickEdit = record => {
    if (!hasInstalledEditApp()) {
      //如果没有安装客户端，下载在线编辑客户端
      Modal.warning({title: '请先下载安装在线编辑客户端'});
      this.downloadBwdaOnlineEdit();
      return;
    }

    const {dispatch} = this.props;
    dispatch({
      type: 'privateFileModel/getEditLinkPath',
      payload: {
        fileId: record.id,
      },
      callback: (res) => {
        if (res.result == "ok") {
          let path = res.data;
          if (path) {
            window.open(path, "_self");
          } else {
            Modal.error({title: '操作失败', content: "缺少路径，无法预览"});
          }

        } else {
          Modal.error({title: '操作失败', content: res.msg});
        }
      },
    });
  };

  /********************end*********无需审批，直接操作 0个人文件下载1公共文件2流转3外发4编辑 *********************/

  queryDownloadRight = (record) => {
    let records = [];
    records.push(record);
    this.queryOptRight(0, records);
  }


  queryFlowRight = (record) => {
    let records = [];
    records.push(record);
    this.queryOptRight(1, records);
  }
  queryOutRight = (record) => {
    let records = [];
    records.push(record);
    this.queryOptRight(2, records);
  }
  queryShareRight = (record) => {
    let records = [];
    records.push(record);
    this.queryOptRight(3, records);
  }
  queryEditRight = (record) => {
    let records = [];
    records.push(record);
    this.queryOptRight(4, records);
  }


  // 共享选人
  handleShare = (records, orgIds, groupIds, shareToAll) => {
    const ids = records.map((item) => {
      return item.id;
    }).join(",");

    let form = {};
    form.fileOrDirId = ids;
    form.shareFlag = 1;
    // 0用户1自定义组2组织3全部
    if (shareToAll) {
      form['shareTo[' + 0 + '].userCode'] = null;
      form['shareTo[' + 0 + '].userType'] = 3;
    } else {
      let orgNums = 0;
      if (orgIds && orgIds.length) {
        for (let i = 0; i < orgIds.length; i++) {
          form['shareTo[' + i + '].userCode'] = orgIds[i];
          form['shareTo[' + i + '].userType'] = 2;
          orgNums++;
        }
      }
      if (groupIds && groupIds.length) {
        for (let j = 0; j < groupIds.length; j++) {
          let num = j + orgNums;
          form['shareTo[' + num + '].userCode'] = groupIds[j];
          form['shareTo[' + num + '].userType'] = 1;
        }
      }


    }


    const {dispatch} = this.props;
    dispatch({
      type: 'privateFileModel/updateFileShare',
      payload: form,
      callback: (res) => {
        if (res.result == "ok") {
          Modal.success({title: res.msg});
          this.handleShareModalVisible();
          this.backToRoot();
        } else {
          Modal.error({title: '操作失败', content: res.msg});
        }
      },
    });


  };
  // 共享modal
  handleShareModalVisible = (flag, records) => {
    this.setState({
      shareModalVisible: !!flag,
      records: records || [],
    });
    if (flag) {
      this.queryOrgTree(); // 组织树请求
      this.queryGroupListByUsercode();//自定义组请求
    }
  };

  isShare = (record) => {
    Modal.confirm({
      title: '取消共享',
      content: '您确定要取消共享吗？',
      okText: '确认',
      cancelText: '取消',
      onOk: () => this.removeShare(record),
    });
  };


  //取消共享
  removeShare = record => {
    const {dispatch,} = this.props;
    dispatch({
      type: 'privateFileModel/updateFileShare',
      payload: {
        fileOrDirId: record.id,
        shareFlag: 0,
      },
      callback: (res) => {
        if (res.result == "ok") {
          Modal.success({title: res.msg});
          this.backToRoot();
        } else {
          Modal.error({title: '操作失败', content: res.msg});
        }
      },
    });
  }

  //更新共享
  updateFileOrDirShare = record => {
    const {dispatch,} = this.props;
    const {currentDir,} = this.state;
    dispatch({
      type: 'privateFileModel/updateFileShare',
      payload: {
        fileOrDirId: record.id,
        shareFlag: record.shareFlag == 1 ? 0 : 1,

      },
      callback: (res) => {
        if (res.result == "ok") {
          Modal.success({title: res.msg});
          this.querySubDirOrFileList(currentDir);
        } else {
          Modal.error({title: '操作失败', content: res.msg});
        }
      },
    });
  };


  SetMostUse = (record) => {
    Modal.confirm({
      title: '收藏',
      content: '您确定要加入收藏吗？',
      okText: '确认',
      cancelText: '取消',
      onOk: () => this.updateFileMostUse(record),
    });
  };

  CancelMostUse = (record) => {
    Modal.confirm({
      title: '取消收藏',
      content: '您确定要取消收藏吗？',
      okText: '确认',
      cancelText: '取消',
      onOk: () => this.updateFileMostUse(record),
    });
  };

  //  更新常用
  updateFileMostUse = record => {
    const {dispatch,} = this.props;
    const {currentDir} = this.state;
    dispatch({
      type: 'privateFileModel/updateFileMostUse',
      payload: {
        fileOrDirId: record.id,
        mostUseFlag: record.mostUseFlag == 1 ? 0 : 1,
      },
      callback: (res) => {
        if (res.result == "ok") {
          Modal.success({title: res.msg});
          this.backToRoot();
        } else {
          Modal.error({title: '操作失败', content: res.msg});
        }
      },
    });
  };


  /***预览文件**/
  previewFile = record => {


    const {dispatch,} = this.props;
    if (!hasInstalledEditApp()) {
      //如果没有安装客户端，下载在线编辑客户端
      Modal.warning({title: '请先下载安装在线编辑客户端'});
      this.downloadBwdaOnlineEdit();
      return;
    }
    //获取编辑地址

    dispatch({
      type: 'privateFileModel/getPreviewLinkPath',
      payload: {
        fileId: record.id,
      },
      callback: (res) => {
        if (res.result == "ok") {

          let path = res.data;
          if (path) {
            window.open(path, "_self");
          } else {
            Modal.error({title: '操作失败', content: "缺少路径，无法预览"});
          }
        } else {
          Modal.error({title: '操作失败', content: res.msg});
        }
      },
    });
  };


  downloadBwdaOnlineEdit = () => {
    window.open("/DSRS-OnlineEdit.exe", "_self");
  }

  handleSelectRows = rows => {
    this.setState({
      selectedRows: rows,
    });
  };


  handleSearch = e => {
    e.preventDefault();
    const {dispatch, form} = this.props;
    const {currentDir} = this.state;

    form.validateFields((err, fieldsValue) => {
      if (err) return;
      if (fieldsValue.fileStatus == "0") {
        fieldsValue.mostUseFlag = 1;
      } else if (fieldsValue.fileStatus == "1") {
        fieldsValue.shareFlag = 1;
      }

      const values = {
        ...fieldsValue,
        updatedAt: fieldsValue.updatedAt && fieldsValue.updatedAt.valueOf(),
        parentId: currentDir.id,
      };

      this.setState({
        formValues: values,
      });

      dispatch({
        type: 'privateFileModel/queryMyFiles',
        payload: values,

      });
    });
  };


  /*****新增修改文件夹名称开始*****/

  addOrUpdateDir = (fields, record) => {
    if (record && record.id) {
      this.renameDir(record, fields.dirName);
    } else {
      this.addDir(fields.dirName);
    }
  };

  /********移动文件到其他地方*******/
  handleMove = (newParentId, record) => {
    const {dispatch,} = this.props;
    dispatch({
      type: 'privateFileModel/moveFile',
      payload: {
        id: record.id,
        newParentId: newParentId || 0,
      },
      callback: (res) => {
        if (res.result == "ok") {
          Modal.success({title: res.msg});
          this.handleMoveModalVisible();
          this.backToRoot();
        } else {
          Modal.error({title: '操作失败', content: res.msg});
        }
      },
    });
  };
  /********复制文件到其他地方*******/
  handleCopy = (newParentId, record) => {
    const {dispatch,} = this.props;
    dispatch({
      type: 'privateFileModel/copyFile',
      payload: {
        id: record.id,
        newParentId: newParentId || 0,
      },
      callback: (res) => {
        if (res.result == "ok") {
          Modal.success({title: res.msg});
          this.handleCopyModalVisible();
          this.backToRoot();
        } else {
          Modal.error({title: '操作失败', content: res.msg});
        }
      },
    });
  };

  /**
   * 新增文件夹
   */
  addDir(dirName) {
    const {dispatch,} = this.props;
    const {currentDir} = this.state;

    dispatch({
      type: 'privateFileModel/addDir',
      payload: {
        parentId: currentDir.id,
        dirName: dirName,
      },
      callback: (res) => {
        if (res.result == "ok") {
          Modal.success({title: res.msg});
          this.handleDirModalVisible();
          this.querySubDirOrFileList(currentDir);
        } else {
          Modal.error({title: '操作失败', content: res.msg});
        }
      },
    });
  }

  /**
   * 重命名文件夹
   */
  renameDir = (record, newDirName) => {
    const {dispatch,} = this.props;
    const {currentDir} = this.state;
    //如果是文件，不能修改文件类型
    if (record && record.dirType == 0 && newDirName) {
      //截取后缀
      let fileName = record.dirName.lastIndexOf(".");//取到文件名开始到最后一个点的长度
      let fileNameLength = record.dirName.length;//取到文件名长度
      let fileFormat = record.dirName.substring(fileName + 1, fileNameLength);//截

      if (!newDirName.endsWith(fileFormat)) {
        Modal.error({title: '操作失败', content: "文件类型不能修改"});
        return;
      }
    }

    dispatch({
      type: 'privateFileModel/updateDir',
      payload: {
        id: record.id,
        dirName: newDirName,
      },
      callback: (res) => {
        if (res.result == "ok") {
          Modal.success({title: res.msg});
          this.handleDirModalVisible();
          this.querySubDirOrFileList(currentDir);
        } else {
          Modal.error({title: '操作失败', content: res.msg});
        }
      },
    });
  }


  handleDirModalVisible = (flag, record) => {
    this.setState({
      dirModalVisible: !!flag,
      record: record || {},
    });
  };

  /**
   * 金库协同
   */
  handleTreasuryVisible = (flag, optType, records) => {
    this.setState({
      treasuryVisible: !!flag,
      records: records || [],
      optType: optType,

    });

  };

  /**
   * 移动文件弹出框
   * @param flag
   * @param record
   */
  handleMoveModalVisible = (flag, record) => {
    this.setState({
      moveModalVisible: !!flag,
      record: record || {},
    });
    if (flag) {
      this.queryDirTreeList();
    }

  };

  handleScanResultModalVisible = (flag,) => {
    this.setState({
      scanResultViewVisible: !!flag,
    });

  };
  /**
   * 查询扫描结果
   * @param flag
   */
  queryScanResult = (record) => {
    const {dispatch} = this.props;
    this.setState({scanRecord:record},()=>{
      const id = record.id;
      dispatch({
        type: 'privateFileModel/queryScanTree',
        payload: {id},
        callback: (res) => {

        },
      });

      this.handleScanResultModalVisible(true);

    })

  };
  /**
   * 复制文件
   * @param flag
   * @param record
   */
  handleCopyModalVisible = (flag, record) => {
    this.setState({
      copyModalVisible: !!flag,
      record: record || {},
    });
    if (flag) {
      this.queryDirTreeList();
    }
  };

  /*****上传成功*****/
  handleUpload = () => {
    const {currentDir} = this.state;
    this.handleUploadModalVisible();
    this.querySubDirOrFileList(currentDir);
    this.queryUserfilespace()
  };

  // 进度条--使用空间
  queryUserfilespace = () => {
    const {dispatch} = this.props;
    dispatch({
      type: 'user/queryUFS',
    });
  }


  /*****流转开始*****/
    // 流转
  handleFlow = (fields, records, selectedUsercodes) => {
    if (!selectedUsercodes) {
      Modal.error({title: '操作失败', content: "请选择接收人"});
      return;
    }

    const ids = records.map((item) => {
      return item.id;
    }).join(",");

    const {dispatch} = this.props;
    let params = {
      fileIds: ids,
      applyTitle: fields.applyTitle,
      applyReason: fields.applyReason,
      auditUserCode: fields.auditUserCode,
      rightConfig: fields.rightConfig,
      toUserCodes: [],
    };
    selectedUsercodes.forEach((item, index) => {
      params.toUserCodes[index] = item.userCode;
    });


    dispatch({
      type: 'privateFileModel/addFlowApply',
      payload: params,
      callback: (res) => {
        if (res.result == "ok") {
          Modal.destroyAll();
          Modal.success({title: res.msg});
          this.handleFlowModalVisible();
        } else {
          Modal.error({title: '操作失败', content: res.msg});
        }
      },
    });


  };
  handleFlowModalVisible = (flag, records, auditSetting) => {
    if (!records) {
      records = [];
    }
    const ids = records.map((item) => {
      return item.id;
    }).join(",");

    this.setState({
      flowModalVisible: !!flag,
      records: records || [],
      auditSetting: auditSetting,
    });
    if (flag) {
      // this.queryOrgTree();
    }
  }
  quickFlow = (records) => {
    // auditSetting 0是无需审批
    this.handleFlowModalVisible(true, records, 0);
  }
  //流转选人，org改变，重新查询人员
  onFlowOrgChange = (orgId) => {
    this.queryUserList(orgId);
  }

  queryUserList = (params) => {
    const {dispatch} = this.props;
    dispatch({
      type: 'privateFileModel/queryUserList',
      payload: params,
      callback: (res) => {
        if (res.result == "ok") {

        } else {
          Modal.error({title: '操作失败', content: res.msg});
        }
      },
    });
  }
  queryGroupListByUsercode = () => {
    const {dispatch} = this.props;
    dispatch({
      type: 'privateFileModel/queryGroupListByUsercode',
      callback: (res) => {
        if (res.result == "ok") {

        } else {
          Modal.error({title: '操作失败', content: res.msg});
        }
      },
    });
  }

  // 批量流转
  batchFlowRight = (rows = []) => {

    this.queryOptRight(1, rows);
  };
  // 批量外发
  batchOutRight = (rows = []) => {

    this.queryOptRight(2, rows);
  };


  // 批量下载
  batchDownload = (rows = []) => {
    this.queryOptRight(0, rows);
  };


  queryOptRight = (optType, records) => {
    const ids = records.map((item) => {
      return item.id;
    }).join(",");

    let payload = {ids, optType: optType};
    const {dispatch} = this.props;
    dispatch({
      type: 'privateFileModel/queryOptRight',
      payload: payload,
      callback: (res) => {
        if (res.result == "ok") {
          if (res.data.auditSetting == -1) {
            Modal.error({title: '操作失败', content: '您没有权限操作'});
            return;
          } else if (res.data.auditSetting == 1) {
            //需要审批
            this.auditOpt(optType, records);
          } else if (res.data.auditSetting == 0) {
            // 无需审批
            this.noneAuditOpt(optType, records);
          } else if (res.data.auditSetting == 2) {
            // 金库
            this.handleTreasuryVisible(true, optType, records);
          }
        } else {
          Modal.error({title: '操作失败', content: res.msg});
        }
      },
    });
  }

  /**
   * 需要审核的操作
   * @param optType
   * @param ids
   */
  auditOpt = (optType, records) => {
    const ids = records.map((item) => {
      return item.id;
    }).join(",");
    //0 下载， 1流转  2外发，3共享 ， 4编辑
    switch (optType) {
      case 0:
        this.handleDownloadModalVisible(true, records);
        break;

      case 1:
        this.handleFlowModalVisible(true, records, 1);
        break;
      case 2:
        this.handleOutModalVisible(true, records,1);
        break;

      case 3:
        this.handleShareModalVisible(true, records);
        break;
      case 4:
        this.handleEditModalVisible(true, records[0]);
        break;
      default:
        break;
    }

  }
  /**
   * 无需审核的操作
   * @param optType
   * @param ids
   */
  noneAuditOpt = (optType, records) => {

//0 下载， 1流转  2外发，3共享 ， 4编辑
    switch (optType) {
      case 0:
        this.confirmQuickDownload(records);
        break;
      case 1:
        this.quickFlow(records);
        break;
      case 2:
        this.quickOut(records);
        break;
      case 3:
        this.quickShare(records);
        break;
      case 4:
        this.quickEdit(records[0]);
        break;
      default:
        break;
    }
  }


  /*****外发开始*****/
  handleOut = async (fields, records) => {
    const ids = records.map((item) => {
      return item.id;
    }).join(",");
    const {dispatch} = this.props;
    let rightConfig = fields.rightConfig;
    let rights = "";
    if (rightConfig) {
      rightConfig.forEach(right => {
        rights = rights + right + ',';
      });
    }

    if (rights) {
      rights = rights.substring(0, rights.length - 1);
    }

    let waterType = fields.waterType;
    let waterTypeWithDot = "";
    if (waterType) {
      waterType.forEach(water => {
        waterTypeWithDot = waterTypeWithDot + water + ',';
      });
    }

    if (waterTypeWithDot) {
      waterTypeWithDot = waterTypeWithDot.substring(0, waterTypeWithDot.length - 1);
    }
    let startTime = fields.startTime ? moment(fields.startTime).format('YYYY-MM-DD HH:mm:ss') : null;
    let endTime = fields.endTime ? moment(fields.endTime).format('YYYY-MM-DD HH:mm:ss') : null;
    let pwd = fields.filePwd;
    if (pwd) {
      pwd =await encode(pwd)
    }

    let params = {
      dirIds: ids,
      applyTitle: fields.applyTitle,
      applyReason: fields.applyReason,
      auditUserCode: fields.auditUserCode,
      outType: fields.outType,
      waterType: waterTypeWithDot,
      readTimes: fields.readTimes,
      filePwd: pwd,
      sendType: fields.sendType,
      fileType: fields.fileType,
      emailAddr: fields.sendType == 1 ? fields.emailAddr : null,
      startTime: startTime,
      endTime: endTime,
      rightConfig: rights,
    };

    dispatch({
      type: 'privateFileModel/out',
      payload: params,
      callback: (res) => {
        if (res.result == "ok") {
          Modal.destroyAll();
          Modal.success({title: res.msg});
          this.handleOutModalVisible();
        } else {
          Modal.error({title: '操作失败', content: res.msg});

        }
      },
    });


  };
  handleOutModalVisible = (flag, records,auditSetting,) => {
    if (!records) {
      records = [];
    }
    const ids = records.map((item) => {
      return item.id;
    }).join(",");
    this.setState({
      outModalVisible: !!flag,
      outFormValues: records[0],
      records: records,
      ids: ids,
      auditSetting: auditSetting,
    });
  };

  quickOut = (records) => {
    this.handleOutModalVisible(true, records);
  };
  quickShare = (records) => {
    this.handleShareModalVisible(true, records);
  };


  handleUploadModalVisible = flag => {
    this.setState({
      uploadModalVisible: !!flag,
    });
  };

  //选中了目录
  onDirSelect = item => {
    //如果是 常用，共享，首页，单独处理
    switch (item.code) {
      case 'index':
        router.push('/filecenter/home-file');
        break;
      case 'private_file':

        let currentDirs1 = [];
        currentDirs1.push({code: 'index', dirName: '我的文件库', id: ''});
        currentDirs1.push({code: 'index', dirName: '个人文件', id: ''});
        this.setState({currentDirs: currentDirs1});
        //查询文件夹下的子文件
        this.querySubDirOrFileList({id: 0});
        break;
      case 'my_share':
        this.setDirLineToShare();
        this.showMyShare();
        break;
      case 'most_use':
        this.setDirLineToMostUse();
        this.showMostUse();
        break;
      case 'sub_file':
        let currentDirs = this.state.currentDirs;
        let newDirs = [];
        for (let sub of currentDirs) {
          newDirs.push(sub);
          if (item.id == sub.id) {
            break;
          }
        }
        //更改当前的显示
        this.setState({currentDirs: newDirs});
        //查询文件夹下的子文件
        this.querySubDirOrFileList({id: item.id});

        break;
      default:
        break;
    }


  }


  renderSimpleForm() {
    const {
      form: {getFieldDecorator},
    } = this.props;

    return (
      <Form onSubmit={this.handleSearch} layout="inline">
        <Row gutter={{md: 8, lg: 24, xl: 48}}>
          <Col md={8} sm={24}>
            <FormItem label="文件名称">
              {getFieldDecorator('dirName')(<Input placeholder="请输入"/>)}
            </FormItem>
          </Col>
          <Col md={8} sm={24}>
            <span className={styles.submitButtons}>
              <Button type="primary" htmlType="submit">
                查询
              </Button>
            </span>
          </Col>
        </Row>
      </Form>
    );
  }

  renderForm() {
    return this.renderSimpleForm();
  }

  render() {
    const {
      privateFileModel: {data, dirTreeList, usersData, groupList, scanData, orgAdmin,},
      loading,
    } = this.props;
    const {
      selectedRows, uploadModalVisible, dirModalVisible, flowModalVisible, outModalVisible,
      records, record, currentDir, moveModalVisible, copyModalVisible, downloadModalVisible, editModalVisible, shareModalVisible, orgTree, currentDirs, supportUploadFileTypes, fileMaxUploadSize, scanResultViewVisible, shareViewVisible, shareViewData, authOptions, waterOptions, treasuryVisible,
      ids, jinkuPeople, jinkuUuid, optType, auditSetting,
    } = this.state;


    //共享详情方法
    const shareViewMethods = {
      shareViewHandelVisible: this.shareViewHandelVisible,
    };
    const scanResultMethods = {
      handleModalVisible: this.handleScanResultModalVisible,
    };

    // 流转的方法
    const flowMethods = {
      handleFlowModalVisible: this.handleFlowModalVisible,
      handleUserSelectModalVisible: this.handleUserSelectModalVisible,
      onFlowOrgChange: this.onFlowOrgChange,
      handleFlow: this.handleFlow,
      queryOrgTree: this.queryOrgTree,
      queryUserList: this.queryUserList,
    };
    //外发的方法
    const outMethods = {
      handleOut: this.handleOut,
      handleModalVisible: this.handleOutModalVisible,
    };
    //新建修改文件夹名称
    const dirMethods = {
      addOrUpdateDir: this.addOrUpdateDir,
      handleModalVisible: this.handleDirModalVisible,
    };
    //移动文件
    const moveMethods = {
      handleMove: this.handleMove,
      handleModalVisible: this.handleMoveModalVisible,
    };
    //移动文件
    const copyMethods = {
      handleCopy: this.handleCopy,
      handleModalVisible: this.handleCopyModalVisible,
    };
    //上传文件
    const uploadMethods = {
      handleUpload: this.handleUpload,
      handleModalVisible: this.handleUploadModalVisible,
    };
    //下载文件
    const downloadMethods = {
      addDownloadApply: this.handleDownload,
      handleModalVisible: this.handleDownloadModalVisible,
    };

    //编辑申请
    const editMethods = {
      addEditApply: this.addEditApply,
      handleModalVisible: this.handleEditModalVisible,
    };
    //下载文件
    const shareMethods = {
      handleShare: this.handleShare,
      handleModalVisible: this.handleShareModalVisible,
    };

    //金库下载
    const treasuryMethods = {
      querySensitive: this.querySensitive,
      querySms: this.querySms,
      checkSensitive: this.checkSensitive,
      handleTreasuryVisible: this.handleTreasuryVisible,
    };
    const configs = getConfigs() || {};

    return (
      <PageHeaderWrapper title="个人文件">
        <Card bordered={false}>
          <div className={styles.tableList}>
            <div className={styles.tableListForm}>{this.renderForm()}</div>

            <div className={styles.tableListOperator2}>
              <Button type="" type="primary" onClick={() => this.showMostUse()}>
                收藏文件
              </Button>
              {configs.hideShare ? null : <Button type="" type="primary" onClick={() => this.showMyShare()}>
                我的共享
              </Button>}

            </div>

            <div className={styles.tableListOperator}>
              {selectedRows.length > 0 && (
                <Fragment>
                  <Button onClick={() => this.batchDelete(selectedRows)}>批量删除</Button>
                  {configs.hideDownload ? null : <Button onClick={() => this.batchDownload(selectedRows)}>批量下载</Button>}

                  <Button onClick={() => this.batchFlowRight(selectedRows)}>批量流转</Button>
                  <Button onClick={() => this.batchOutRight(selectedRows)}>批量外发</Button>
                </Fragment>
              )}
              <Button icon="upload" type="primary" onClick={() => this.handleUploadModalVisible(true)}>
                上传
              </Button>
              <Button icon="plus" type="primary" onClick={() => this.handleDirModalVisible(true)}>
                新建文件夹
              </Button>
            </div>
            <div style={{clear: 'both'}}></div>
            <div className={styles.filePath}>
              <DirLine dirs={currentDirs} onDirSelect={this.onDirSelect}/>
            </div>
            <TableList
              className={styles.tdPadding}
              selectedRows={selectedRows}
              loading={loading}
              data={data}
              // hideRowSelection={true}
              columns={this.columns}
              onSelectRow={this.handleSelectRows}
              onChange={this.handleStandardTableChange}
            />
          </div>
        </Card>

        {/*金库协同*/}
        {treasuryVisible ? (
          <TreasurySynergy
            {...treasuryMethods}
            treasuryVisible={treasuryVisible}
            records={records}
            optType={optType}
            jinkuPeople={jinkuPeople}
            jinkuUuid={jinkuUuid}/>
        ) : null}


        {/* 流转*/}
        {records && records.length ? (
          <FlowCreateForm {...flowMethods} modalVisible={flowModalVisible} records={records} orgTree={orgTree}
                          auditSetting={auditSetting}
                          loading={loading}
                          usersData={usersData}
                          orgAdmin={orgAdmin}/>
        ) : null}


        {/*外发*/}
        {records && records.length ? (
          <OutCreateForm {...outMethods} modalVisible={outModalVisible} records={records} authOptions={authOptions}
                         waterOptions={waterOptions} ids={ids} orgAdmin={orgAdmin} auditSetting={auditSetting}/>
        ) : null}


        {/*新建修改文件夹*/}
        <CreateOrUpdateDirForm {...dirMethods} modalVisible={dirModalVisible} record={record}/>

        <MoveFileForm {...moveMethods} modalVisible={moveModalVisible} record={record} dirTreeList={dirTreeList}/>

        <CopyFileForm {...copyMethods} modalVisible={copyModalVisible} record={record} dirTreeList={dirTreeList}/>

        {/*上传文件*/}
        {uploadModalVisible ?
          <UploadFileForm {...uploadMethods} modalVisible={uploadModalVisible} currentDir={currentDir}
                          supportUploadFileTypes={supportUploadFileTypes}
                          fileMaxUploadSize={fileMaxUploadSize}/> : null}

        {/*申请下载个人文件*/}
        <SimpleDownloadApplyCreateForm {...downloadMethods} modalVisible={downloadModalVisible} records={records}
                                       orgAdmin={orgAdmin}/>

        {/*编辑申请*/}
        <EditApplyCreateForm {...editMethods} modalVisible={editModalVisible} record={record} orgAdmin={orgAdmin}/>


        {records && records.length ? (
          <ShareToForm {...shareMethods} modalVisible={shareModalVisible} records={records} groupList={groupList}
                       orgTree={orgTree}/>
        ) : null}


        {/*查看共享详情*/}
        <ShareView {...shareViewMethods} shareViewVisible={shareViewVisible} shareViewData={shareViewData}/>
        <ScanResultFormNew {...scanResultMethods} modalVisible={scanResultViewVisible} scanData={scanData} scanRecord={this.state.scanRecord} />
      </PageHeaderWrapper>
    );
  }
}


class ShareView extends PureComponent {
  render() {
    const {shareViewVisible, shareViewHandelVisible, shareViewData} = this.props;
    let whole = [];
    let orgList = [];
    let groupList = [];

    let hasShareToAll = false;
    let hasShareToGroup = false;
    let hasShareToOrg = false;

    shareViewData.forEach(item => {
      // 0用户1自定义组2组织3全部
      switch (item.userType) {
        case 0:
          break;
        case 1:
          hasShareToGroup = true;
          groupList.push(<span>{item.userName}&nbsp;&nbsp;&nbsp;&nbsp;</span>);

          break;
        case 2:
          hasShareToOrg = true;
          orgList.push(<span>{item.userName}&nbsp;&nbsp;&nbsp;&nbsp;</span>);
          break;
        case 3:
          hasShareToAll = true;
          whole.push(<Col md={12}>
            <FormItem {...formLayout} label="所有人">
              共享给所有人
            </FormItem>
          </Col>)
          break;
      }

    })

    return (
      <Modal
        destroyOnClose
        width={800}
        title="查看共享详情"
        visible={shareViewVisible}
        onOk={() => shareViewHandelVisible()}
        onCancel={() => shareViewHandelVisible()}
        footer={[
          <Button key="back" type="primary" onClick={() => shareViewHandelVisible()}>返回</Button>
        ]}
      >
        <Row gutter={16}>
          {hasShareToAll ? whole : null}
          {hasShareToOrg ? <Col md={24}>
            <FormItem labelCol={{span: 3}} wrapperCol={{span: 21}} label="组织机构">
              {orgList}
            </FormItem>
          </Col> : null}
          {hasShareToGroup ? <Col md={24}>
            <FormItem labelCol={{span: 3}} wrapperCol={{span: 21}} label="自定义组">
              {groupList}
            </FormItem>
          </Col> : null}


        </Row>
      </Modal>
    );
  }
}

export default PrivateFile;
